import { LogTypes, LogStatus } from "../common/enums"

let timerId = ''
export const WsNotifyType = {
    add_log: {
        type: 'add_log',
        notify: ({ data: messageData, onNotify }) => {
            const { type: logType } = messageData.data || {}
            const { status } = messageData.data.data || {}

            if (logType === LogTypes.step && status !== LogStatus.start) {
                clearTimeout(timerId)
                timerId = setTimeout(onNotify, 300)
            }
        }
    },
    add_plan: {
        type: 'add_plan',
        notify: ({ onNotify }) => {
            onNotify()
        }
    }
}